package com.wtwd.campus.attendancereceiver;

import com.wtwd.campus.entity.MqAttendanceData;
import com.wtwd.campus.service.InjectFeignService;
import io.netty.channel.Channel;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HeartBeatReceiver implements AttendanceReceiver {
    private static final Logger logger= LoggerFactory.getLogger(HeartBeatReceiver.class);
    @Override
    public String parseMessage(String data, Channel channel) {
        //首先进行校验位的校验
        boolean b = judgeSecurity(data);
        if (b) {
            //获取考勤机序列号
            String subData = data.substring(10, data.length() - 4);
            String proNo = getProNo(subData);
            //校验成功，心跳指令只是维护一个在线状态，故直接回复即可
            logger.info("回复考勤机心跳指令：{}",data);
            channel.writeAndFlush(data);
            return proNo;
        }
        return null;
    }



}
